package com.pkx.cloud.fse7.dms.organization.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pkx.cloud.fse7.dms.organization.entity.Organization;
import com.pkx.cloud.fse7.dms.organization.service.OrganizationService;
import com.pkx.cloud.whzx.comn.ORpose;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 控制器
 *
 * @author chenwg
 * @since 2020-11-17
 */
@RestController
@RequestMapping("/dms/organization")
@Api(value = "组织", tags = "组织")
@Slf4j
@ORpose
public class OrganizationController {

    @Autowired
    private OrganizationService organizationService;

    @ApiOperation("分页列表")
    @GetMapping("/page")
    public Page<Organization> page(Page page, Organization organization) {
        return organizationService.pageList(page, organization);
    }

    @ApiOperation("列表")
    @GetMapping("/list")
    public List<Organization> list(Organization organization) {
        return organizationService.listByEntity(organization);
    }

    @ApiOperation("详情")
    @GetMapping(value = "/{id}")
    public Organization selectById(@PathVariable("id") Long id) {
        return organizationService.selectById(id);
    }

    @ApiOperation("新增")
    @PostMapping("")
    public Boolean add(@RequestBody Organization organization) {
        return organizationService.saveOrganization(organization);
    }

    @ApiOperation("修改")
    @PutMapping("")
    public Boolean modify(@RequestBody Organization organization) {
        return organizationService.modify(organization);
    }

    @ApiOperation("删除(单个条目)")
    @DeleteMapping(value = "/{id}")
    public Boolean deleteById(@PathVariable("id") String id) {
        return organizationService.deleteById(id);
    }
}
